@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/admin/pagenum.css')}}" rel="stylesheet" />
@endsection

@section('html-body')
    <!-- content start -->
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="#">科室列表</a>
        </div>
        <!-- cur-position end -->

        <!-- filter-box start -->
        <div class="filter-box clearfix">
            <div class="fr">
                <a class="addBtn" href="{{route('Admin.Index.createContent')}}">新增</a>
            </div>
        </div>
        <!-- filter-box end -->

        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>预览图</th>
                    <th>标题</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="fansinfo">
                @if($keshis && count($keshis) > 0)
                    @foreach($keshis as $keshi)
                        <tr>
                            <td>{{$keshi->id}}</td>
                            <td class="account-td">
                                <span class="photo" style="border-radius: 100%;display:initial">
                                    <img src="{{route('Api.Image.Show',['id'=>$keshi->img_id])}}" alt="">
                                </span>
                            </td>
                            <td>{{$keshi->title}}</td>
                            <td class="btna"><a href="{{route('Admin.Index.createContent')}}?id={{$keshi->id}}" >修改</a> ｜ <a href="javascript:void(0);" data-id="{{$keshi->id}}">删除</a></td>
                        </tr>
                    @endforeach
                    @endif
                </tbody>
            </table>
        </div>
        <div>
            {{--{!! $orders->render() !!}--}}
        </div>
    </div>
    <!-- content end -->
    <script type="text/javascript">

        $(function() {
            jQuery.ajaxSetup({
                case: false,
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $('.btna a').click(function(){
                var id = $(this).attr('data-id');
                $.ajax({
                    type:"post",
                    url:'{{route('Api.Article.delArticle')}}',
                    dataType:"json",
                    data:{'id':id},
                    success:function(obj){
                        if(obj.level == "success"){
                            noty({text:obj.message,type:obj.level,timeout:800,
                                callback:{
                                    afterClose:function(){
                                        location.reload();
                                    }
                                }
                            });
                        }
                    },
                    error:function(obj){
                        var datajson = obj.responseJSON;
                        noty({text: datajson.message, type: 'error', timeout: 600});
                    }
                });
            });


            //按回车登录
            $(document).keyup(function(event){
                if(event.keyCode ==13){
                    $(".search-smt").trigger("click");
                }
            });
        });
    </script>
@endsection